package com.example.mybatisify.service.impl;

import com.example.mybatisify.entities.Document;
import com.example.mybatisify.healper.LuceneHelper;
import com.example.mybatisify.mapper.DocumentMapper;
import com.example.mybatisify.service.IDocumentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author me
 * @since 2024-06-25
 */
@Service
public class DocumentServiceImpl extends ServiceImpl<DocumentMapper, Document> implements IDocumentService {
    @Scheduled(cron = "0 0 0 * * ?")
    public void updateIndex() {
        try {
            LuceneHelper.constructIndex(this.list(), true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
